package com.douqu.game.main.server.entity;

import com.douqu.game.core.config.common.GoodsData;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.util.StringUtils;

import java.util.Arrays;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-01-20 12:14
 */
public class MailSingle {

    private String title;

    private String content;

    private GoodsData[] attachArray;

    private long createTime;

    public MailSingle()
    {
        this.createTime = DataFactory.currentTime;
    }

    public boolean check()
    {
        if(StringUtils.isNullOrEmpty(title) || StringUtils.isNullOrEmpty(content))
            return false;

        if(attachArray == null)
            return false;

        return true;
    }

    public String getAttachStr()
    {
        if(attachArray == null || attachArray.length == 0)
            return "";

        StringBuilder builder = new StringBuilder();
        for(GoodsData goodsData : attachArray)
        {
            builder.append(goodsData.getGoodsStr());
            builder.append(",");
        }
        return builder.substring(0, builder.length()-1);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public GoodsData[] getAttachArray() {
        return attachArray;
    }

    public void setAttachArray(GoodsData[] attachArray) {
        this.attachArray = attachArray;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "SingleMail{" +
                "title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", attachArray=" + Arrays.toString(attachArray) +
                '}';
    }
}
